<template>
  <div class="km-detail" :class="{'navMenu': navMenuState}" v-loading="loading">
    <div class="searc clearfix" @keyup.enter="handleIconClick">
      <el-input
        class="fl"
        style="width: 320px;margin-left:20px"
        size="mini"
        :placeholder="$t('km.inputKeyWord')"
        v-model.trim="input2">
        <i
          class="el-input__icon el-icon-search"
          slot="suffix"
          @click="handleIconClick">
        </i>
      </el-input>
      <div class="fr">
        <el-button type="primary" class="primary_btn km-button" size="mini" @click.stop="open('import')" v-if="showImport">{{$t('config.customer.import')}}</el-button>
        <el-button type="primary" class="primary_btn km-button" size="mini" @click.stop="open('export')" v-if="showExport">{{$t('public.export')}}</el-button>
      </div>
    </div>
    <div class="searchResult" v-if="isSearch">
      <div class="km-keyword-search-form find">
        <div class="keywrod-wrap">
          <span v-show="searchBack">
            <i class="icon el-icon-arrow-left" @click="searchBackFun"></i>
          </span>
          <span class="search-bread">
            <template v-for="item in newCatalogue">
              <template v-if="item"> {{item + '>'}}</template>
            </template>
          </span>
          <span class="search-hight">
            {{ $t('km.currSearchKeyWord') }} <span class="high">{{ input2 }}</span>
          </span>
        </div>
        <div class="page" v-show="searchEdit === false && searchItemShow === false">
          <span class="fl all">{{ $t('km.gong') }}{{ count }}{{ $t('km.tiaoJiLu') }} |</span>
          <span class="currentpage">{{ page }}/{{ totalPage }}</span>
          <el-pagination
            small
            layout="prev, next, jumper"
            :current-page="page"
            @current-change="dicPageChange"
            :total="count"
          >
          </el-pagination>
        </div>
      </div>
      <div class="searchResultBox">
        <div class="resultList" v-show="searchList">
          <div v-for="(item, index) in list" class="result" :key="index">
            <div class="head">
              <h3 v-html="item.title" class="fl" @click="showSearchContent(item)"></h3>
              <span @click="delText(item)" class="fr" v-if="hasManage && !forbiddenDelete">
                <i class="iconfont icon-guanbi"></i>
              </span>
              <span @click="editText(item)" class="fr" v-if="hasManage">
                <i class="iconfont icon-beizhu"></i>
              </span>
            </div>
            <p v-html="item.content" class="search-content"></p>
            <p class="detai" v-text="item.catalog"></p>
            <p class="detai" v-text="item.lastTime"></p>
          </div>
        </div>
        <div class="modification" v-show="searchEdit">
          <km-modify ref="searchEditModules" @edit="editContent" :KmType="KmType"></km-modify>
        </div>
        <div class="contentDetails" v-if="searchItemShow">
          <h2 class="content-title" v-html="title"></h2>
          <div class="content" v-html="replaceKeyWord(ItemContent, input2)" @click="superAClickFun"></div>
          <div class="file km-file" style="margin-top: 10px">
            <span v-for="(one, index) in attached" :key="index" style="padding-right: 15px">
              <globalPopup
                style="display: inline-block; margin-bottom: 5px"
                :url="km.getKmUrl({ [index]: one })"
                :key="km.getKmUrl({ [index]: one })"
                @showBigImage="showBigImage"
                :name="one.replace(/\s/g, '')"
                :currObj="{ url: km.getKmUrl({ [index]: one }), isKm: true }"
                :srcUrl="km.getKmUrl({ [index]: one })"
                :imgObj="[]"
              ></globalPopup>
            </span>
          </div>
          <knowledgeLabel :tagList="tagList" :isPreview="true"></knowledgeLabel>
          <div class="comment">
            <km-comment></km-comment>
          </div>
        </div>
      </div>
    </div>
    <div class="public" v-if="showItem">
      <div class="catalogue-list" v-show="newCatalogue[0]">
        <!--<span>{{$t('km.catalogLook')}} ></span><span v-html="catalogue"></span>-->
        <bread-crumb
          :first="newCatalogue[0]"
          :second="newCatalogue[1]"
          :third="newCatalogue[2]"
          :forth="newCatalogue[3]"
          :fifth="newCatalogue[4]"
          :cataPath="cataPath"
          :cataLength="cataLength"
          @pauseVideo="pauseVideo"
        ></bread-crumb>
      </div>
      <div>
        <div v-show="ok">
          <div class="km-keyword-search-form" v-if="root === 'curupdate'">
            <el-button
              size="small"
              class="primary_btn"
              :type="recentSearchType === 'day' ? 'primary' : ''"
              @click="recentList('day')"
              >{{ $t('km.nearly24Hours') }}</el-button
            >
            <el-button
              size="small"
              class="primary_btn"
              :type="recentSearchType === 'week' ? 'primary' : ''"
              @click="recentList('week')"
              >{{ $t('questionnaire.ques_oneWeek') }}</el-button
            >
            <el-button
              size="small"
              class="primary_btn"
              :type="recentSearchType === 'month' ? 'primary' : ''"
              @click="recentList('month')"
              >{{ $t('questionnaire.ques_oneMounth') }}</el-button
            >
          </div>
          <div class="km-keyword-search-form" v-if="root !== 'curupdate'">
            <!--all为目录浏览，不允许添加知识库-->
            <div class="search">
              <div class="pd" v-if="hasManage && deptPower">
                <span class="plus" @click.stop="plus" v-if="$route.params.kmId !== 'all'">
                  <i class="el-icon-plus"></i>
                  {{ $t('public.add') }}
                </span>
              </div>
            </div>
            <div class="page">
              <span class="fl all xxxxxx">{{ $t('km.gong') }}{{ tableCount }}{{ $t('km.tiaoJiLu') }} |</span>
              <span class="currentpage">{{ tablePage }}/{{ tableTotalPage }}</span>
              <el-pagination
                small
                layout="prev, next, jumper"
                :current-page="tablePage"
                @current-change="currentChange"
                :total="tableCount"
              >
              </el-pagination>
            </div>
          </div>
          <kmTable
            ref="kmTable"
            :recent="recent"
            @pages="pages"
            @sorTableFun="sorTableFun"
            :currentpage="tablePage"
            :tableData="tableData"
            :KmType="KmType"
            @editBtn="editBtnContent"
            @show="showContent"
            @multipleSelection="multipleSelection"
            @addData="addData"
            :root="root"
            :hasManage="hasManage"
            :forbiddenDelete="forbiddenDelete"
            :forbiddenPlaceTop="forbiddenPlaceTop"
            @handlePlaceTop="handlePlaceTop"
          ></kmTable>
          <div class="batch" v-if="batch.operator && batch.operator.length" :class="{ show: batch.isBatchShow, navMenuState: navMenuState }">
            <el-checkbox v-model.trim="batch.allChecked" @change="selectAll">{{ $t('public.checkAll') }}</el-checkbox>
            <card-batch
              v-if="batch.operator"
              :tabType="batch.tabType"
              :batchOperator="batch"
              @checkNone="checkNone"
              @onDelete="onDelete"
              @onModifyCid="onModifyCid"
              @onModifyDate="onModifyDate"
            ></card-batch>
          </div>
        </div>
        <div class="new-add" v-if="ifAdd">
          <km-newAdd @addKm="addContent" @cancel="cancel" :KmType="KmType"></km-newAdd>
        </div>
        <div class="modification" v-show="ifEdit">
          <km-modify ref="editModules" @edit="editContent" :KmType="KmType"></km-modify>
        </div>
        <div class="contentDetails" v-if="ifContent">
          <h2 class="content-title" v-html="title"></h2>
          <div class="content" v-html="replaceKeyWord(ItemContent, input2)" @click="superAClickFun"></div>
          <div class="file km-file" style="margin-top: 10px">
            <span v-for="(one, index) in attached" :key="index" style="padding-right: 15px">
              <globalPopup
                style="display: inline-block; margin-bottom: 5px"
                :url="km.getKmUrl({ [index]: one })"
                :key="km.getKmUrl({ [index]: one })"
                @showBigImage="showBigImage"
                :name="one.replace(/\s/g, '')"
                :currObj="{ url: km.getKmUrl({ [index]: one }), isKm: true }"
                :srcUrl="km.getKmUrl({ [index]: one })"
                :imgObj="[]"
              ></globalPopup>
            </span>
          </div>
          <knowledgeLabel :tagList="tagList" :isPreview="true"></knowledgeLabel>
          <div class="comment">
            <km-comment></km-comment>
          </div>
        </div>
      </div>
    </div>
    <el-dialog :close-on-click-modal="false" modal-append-to-body lock-scroll :title="dialogTitle" :visible.sync="dialogVisible" :width="dialogType === 'import'? '50%': '30%'" v-loading="dialogLoading" element-loading-text="正在解析...">
      <div v-show="dialogType === 'import'">
        <div class="btn-wrap">
          <el-button type="info" class="temp-download primary_btn">
            <a :href="'/static/template/km-'+ KmType +'_'+ 'zh_CN.xlsx'" download>{{$t('km.downloadImport')}}</a>
          </el-button>
          <!--饿了么上传组件-->
          <el-upload
            class="temp-upload"
            :action="uploadUrl"
            accept=".xls,.xlsx"
            name="upload"
            :data="uploadHeaders"
            :with-credentials="true"
            :on-success="handleSuccess"
            :on-error="handleError"
            :before-upload="beforeUpload"
            :show-file-list="false">
            <el-button class="primary_btn" type="primary">{{$t('km.importName')}}</el-button>
          </el-upload>
        </div>
        <div class="import" v-show="importShow">
          <el-row :gutter="20">
            <el-col :span="4" class="label">{{$t('km.batchNo')}}</el-col>
            <el-col :span="10"><el-input v-model.trim="importObj.batchNo" :disabled="true"></el-input></el-col>
            <el-col :span="10"><el-input v-model.trim="importObj.batchRemark" @click.enter="importExcel" :placeholder="$t('km.batchNoMark')"></el-input></el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="4" class="label">{{$t('km.titleRepeat')}}</el-col>
            <el-col :span="10" style="line-height: 30px">
              <el-radio-group v-model.trim="importObj.titleRepeat">
                <el-radio label="cover">{{$t('km.kmCover')}}</el-radio>
                <el-radio label="skip">{{$t('km.kmSkip')}}</el-radio>
              </el-radio-group>
            </el-col>
          </el-row>
          <el-button class="primary_btn margin-t" @click.stop="importExcel" type="primary">{{$t("config.customer.import")}}</el-button>
        </div>
        <div v-if="importErrRows.length" class="padding10">
          <p class="error-title">{{$t('km.dataError')}}</p>
          <p>{{importErrRows.join(", ")}}</p>
        </div>
        <div class="instructions" v-html="$t('km.importTips')" v-once>
        </div>
      </div>
      <div v-show="dialogType === 'export'">
        <span class="label">{{$t("km.pleaseChoice")}}</span>
        <export-catalogue :treeData="treeData" ref="export"></export-catalogue>
        <p style="margin: 14px 0 10px 0;">{{$t("km.pleaseChoiceStyle")}}</p>
        <el-radio-group v-model.trim="delTags" style="margin-bottom: 14px;">
          <el-radio :label="false">{{$t('km.pleaseChoiceWithStyle')}}</el-radio>
          <el-radio :label="true">{{$t('km.pleaseChoiceNoStyle')}}</el-radio>
        </el-radio-group>
        <br>
        <div style="text-align:center">
          <el-button class="primary_btn" @click.stop="dialogVisible = false" type="">{{$t("public.cancel")}}</el-button>
          <el-button class="primary_btn" @click.stop="exportExcel" type="primary">{{$t("public.export")}}</el-button>
        </div>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="batchUpdateCidShow" :close-on-click-modal="false" modal-append-to-body lock-scroll top="10%" :title="$t('km.batchUpdateCid')" width="50%">
      <kmTree
        :KmType="KmType"
        type='webchat'
        :manage="1"
        @childId="childId"
        treeHeight="300px"
        ref="kmTree"
      ></kmTree>
      <p>
        {{ $t('km.targetDirectory') + targetName }}
      </p>
      <span slot="footer" class="dialog-footer">
        <el-button class="primary_btn" @click.stop="closeCid">{{$t('public.cancel')}}</el-button>
        <el-button type="primary" class="primary_btn" @click.stop="submitCid">{{$t('public.save')}}</el-button>
      </span>
    </el-dialog>
    <el-dialog :visible.sync="batchUpdateValidShow" :close-on-click-modal="false" modal-append-to-body lock-scroll top="10%" :title="$t('km.batchUpdateValid')" width="50%">
      <el-form label-position="right" :rules="rules" ref="form" :model="form">
        <el-form-item :label="$t('km.knowledgeValidity')" prop="validityPeriodType">
          <el-select v-model="form.validityPeriodType" :placeholder="$t('public.pleasePick')" @change="validityChange" style="width: 400px">
            <el-option v-for="item in validityOption" :label="item.label" :value="item.value" :key="item.value">
            </el-option>
          </el-select>
          <el-date-picker
            v-if="form.validityPeriodType === 'custom'"
            v-model="form.validityPeriod"
            class="custom_time"
            type="datetimerange"
            :placeholder="$t('public.timeRanges')"
            @change="validTimeChange"
          >
          </el-date-picker>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button class="primary_btn" @click.stop="closeValid">{{$t('public.cancel')}}</el-button>
        <el-button type="primary" class="primary_btn" @click.stop="submitValid">{{$t('public.save')}}</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
  import KmTable from '@/components/business-modules/km/km-detail/KmTable.vue'
  import KmNewAdd from '@/components/business-modules/km/km-detail/KmNewAdd.vue'
  import KmModify from '@/components/business-modules/km/km-detail/KmModify.vue'
  import KmComment from '@/components/business-modules/km/km-detail/KmComment.vue'
  import globalPopup from '@/components/ui-modules/affix/globalPopup.vue'
  import BreadCrumb from '@/components/ui-modules/breadCrumb/BreadCrumb.vue'
  import {getDateNo, deepClone, isHasFunc, filterXSS, getFormatDateTime} from '@/utils/m7Utils.js'
  import bus from '@/store/eventBus'
  import {checkform} from '@/utils/validate'
  import { commitImgType2 } from '@/utils/publicMethod.js'
  import knowledgeLabel from './knowledgeLabel.vue'
  import { km } from '@/utils/cosUrl'
  import exportCatalogue from '@/components/business-modules/km/km-search/exportCatalogue'
  import cardBatch from '@/components/public-modules/card/CardBatch'
  import kmTree from '@/components/business-modules/km/km-search/KmTree.vue'
  export default {
    name: 'kmDetail',
    props: ['treeChilds'],
    data () {
      return {
        dataType: ['pdf', 'PDF', 'txt', 'TXT'],
        bigImage: {
          bigImageShow: false,
          url: ''
        },
        loading: true,
        ok: true,
        ifEdit: false,
        ifAdd: false,
        ifContent: false,
        ItemContent: [],
        editdata: {},
        title: '',
        isSearchDetail: false,
        delContent: '',
        addId: '',
        tableData: [],
        catalogue: '',
        page: 1,
        totalPage: 1,
        input2: '',
        isSearch: false,
        searchEdit: false,
        searchList: false,
        searchItemShow: false,
        searchBack: false,
        showItem: true,
        list: [],
        count: 0,
        tablePage: 1,
        tableTotalPage: 1,
        tableCount: 0,
        attached: '',
        root: 'curupdate',
        hasManage: false,
        forbiddenDelete: false,
        forbiddenPlaceTop: false,    //  置顶权限
        newCatalogue: ['', '', '', '', ''],
        cataPath: [],
        sortTableObj: {},
        cataLength: 1,
        recentSearchType: 'day', // 最近更新时间
        tagList: [],
        km,
        batch: {
          batchItem: [],
          allChecked: false,
          isBatchShow: false,
          checkedCount: 0,
          tabType: 'km',
          operator: []
        },
        batchUpdateCidShow: false,
        batchUpdateValidShow: false,
        targetCid: '',
        targetName: '',
        form: {
          validityPeriodType: '',
          validityPeriod: []
        },
        rules: {
          validityPeriodType: [{ required: true, message: this.$t('km.knowledgeValidityTip'), trigger: 'change' }]
        },
        validityOption: [
          {
            label: '永久有效',
            value: 'permanent'
          },
          {
            label: '无效',
            value: 'invalid'
          },
          {
            label: '自定义有效期',
            value: 'custom'
          }
        ],
        dialogVisible: false,
        dialogType: 'import',
        dialogLoading: false,
        uploadUrl: '/kmUpload',
        uploadHeaders: {
          type: 'undefined',
          module: '',
          sessionId: this.$store.state.session.sessionId
        },
        // 导入请求参数
        importObj: {
          kmType: '',
          batchNo: '',
          batchRemark: '',
          heads: [],
          titleRepeat: 'cover'
        },
        // 导入按钮显示或隐藏
        importShow: false,
        // 导入错误信息
        importErrRows: [],
        treeData: [{
          name: this.$t('public.all'),
          childs: [],
          _id: '0'
        }],
        delTags: false, // 导出 请选择导出样式
        showImport: false,
        showExport: false
      }
    },
    watch: {
      backTable(to, from) {
        this.ifEdit = false
        this.ifAdd = false
        this.ok = true
        this.ifContent = false
      },
      // 刷新右侧内容
      refreshRight(val) {
        this.refreshRightFun(val)
      },
      refreshPage() {
        this.tablePage = 1
      }
      //      $route (to, from) {
      //        if (to.path.split('/')[2] === 'km') {
      //
      //          }
      //        }
      //      }
    },
    computed: {
      refreshRight() {
        return this.$store.state.km.refreshRight
      },
      refreshPage() {
        return this.$store.state.km.refreshPage
      },
      backTable() {
        return this.$store.state.km.backTable
      },
      recent() {
        return this.$store.state.km.recentList
      },
      KmType() {
        return this.$route.path.split('/')[3]
      },
      navMenuState() {
        return this.$store.state.navMenuState || false
      },
      // 所在部门是否有权限
      deptPower() {
        return this.$store.state.km.itemList.message !== 'no permission'
      },
      dialogTitle () {
        return this.dialogType === 'import' ? this.$t('km.import') : '导出知识库'
      },
    },
    created() {
      console.log(this.attached)
    },
    methods: {
      pauseVideo() { // 暂停富文本里的视频播放
        this.$refs.editModules.pauseVideo()
      },
      validityChange(val) {
        if (val === 'custom') {
          this.form.validityPeriod = [
            getFormatDateTime(new Date()),
            getFormatDateTime(new Date()).split(' ')[0] + ' 23:59:59'
          ]
        }
      },
      validTimeChange(val) {
        if (val && val.length) {
          const end = val[1].getTime()
          const start = val[0].getTime()
          if (end - start < 1 * 60 * 1000) {
            this.$message.error(this.$t('km.timeTip'))
            this.form.validityPeriod = [
              getFormatDateTime(new Date()),
              getFormatDateTime(new Date()).split(' ')[0] + ' 23:59:59'
            ]
          }
        }
      },
      childId(cid) {
        this.targetCid = cid
        this.getTargetCid(cid)
      },
      getTargetCid(cid) {
        const tree = this.$store.state.km.catalogTree || []
        const name = this.treeFindPath(tree, data => data._id === cid, "name")
        this.targetName = name.join('/')
      },
      treeFindPath(tree, func, field = "", path = []) {
        if (!tree) return []
        for (const data of tree) {
          field === "" ? path.push(data) : path.push(data[field]);
          if (func(data)) return path
          if (data.childs) {
            const findChildren = this.treeFindPath(data.childs, func, field, path)
            if (findChildren.length) return findChildren
          }
          path.pop()
        }
        return []
      },
      checkNone() {
        let that
        if (self && self.$refs) {
          that = self
        } else {
          that = this
        }
        that.batch.allChecked = false
        that.batch.batchItem = []
        that.batch.isBatchShow = false
        if (this.$refs.kmTable) {
          this.$refs.kmTable.clearSelection()
        }
      },
       onModifyDate() { // 批量修改有效期
      this.batchUpdateValidShow = true
      this.form.validityPeriodType = '' // 清空数据
      this.$nextTick(() => {
        this.$refs.form.clearValidate()
      })
    },
    closeValid() {
      this.batchUpdateValidShow = false
    },
    submitValid() {
      this.$refs.form.validate(valid => {
        if (valid) {
          let data = {
            kmType: this.KmType,
            validityPeriodType: this.form.validityPeriodType
          }
          if (this.form.validityPeriodType === 'custom') {
            data.validityPeriod = [getFormatDateTime(this.form.validityPeriod[0]), getFormatDateTime(this.form.validityPeriod[1])]
          }
          if (this.batch.allChecked && this.root !== 'curupdate') { // 非 最近更新 全选
            data.isAll = true
            data.currentCid = this.$route.path.split('/')[4]
          } else {
            data.ids = this.batch.batchItem
          }
          this.$store.dispatch('batchUpdateValidityPeriod', data).then((res) => {
            if (res.success) {
              this.closeValid() // 关闭弹框
              if(res.message == 'no permission'){
                this.$message.error(this.$t('km.noPermission'))
                return
              }  
              this.$message.success(this.$t('km.updateValidSuccess'))
              this.$store.commit('km/REFRESH_RIGHT', {type: 'init'})
            }
          })
        }
      })
    },
    onModifyCid() { // 批量修改目录
      this.batchUpdateCidShow = true
    },
    closeCid() {
      this.batchUpdateCidShow = false
    },
    submitCid() {
      let data = {
        kmType: this.KmType,
        cid: this.targetCid
      }
      if (this.batch.allChecked && this.root !== 'curupdate') { // 非 最近更新 全选
        data.isAll = true
        data.currentCid = this.$route.path.split('/')[4]
      } else {
        data.ids = this.batch.batchItem
      }
      this.$store.dispatch('batchUpdateCid', data).then((res) => {
        if (res.success) {
          this.closeCid() // 关闭弹框
          if(res.message == 'no permission'){
            this.$message.error(this.$t('km.noPermission'))
            return
          }  
          this.$message.success(this.$t('km.updateCatalogueSuccess'))
          this.$store.commit('km/REFRESH_RIGHT', {type: 'init'})
        }
      })
    },
    onDelete() { // 批量删除
      this.$confirm(this.$t('monitor.deleteTips'), this.$t('public.operate'), {
        confirmButtonText: this.$t('public.confirm'),
        cancelButtonText: this.$t('public.cancel'),
        cancelButtonClass: 'primary_btn',
        confirmButtonClass: 'primary_btn',
        type: 'warning'
      })
        .then(() => {
          let data = {
            kmType: this.KmType
          }
          if (this.batch.allChecked && this.root !== 'curupdate') { // 非 最近更新 全选
            data.isAll = true
            data.currentCid = this.$route.path.split('/')[4]
          } else {
            data.ids = this.batch.batchItem
          }
          this.$store.dispatch('batchDelItem', data).then((res) => {
            if (res.success) {
              this.$store.commit('km/REFRESH_RIGHT', { type: 'cache' })
              this.$message({
                type: 'success',
                message: this.$t('km.deleteSucc')
              })
            }
          })
        })
        .catch(() => {})
    },
    selectAll(data) {
      if (data) {
        this.$refs.kmTable.checkAll()
        this.batch.allChecked = true
        if (this.root === 'curupdate') { // 最近更新
          this.batch.checkedCount = this.recent.length
        } else {
          this.batch.checkedCount = this.tableCount
        }
      } else {
        this.$refs.kmTable.clearSelection()
      }
    },
    multipleSelection(data) {
      let checkedArr = data.map((item) => item._id)
      this.batch.batchItem = checkedArr
      this.batch.isBatchShow = checkedArr.length > 0
      let bCheck
      if (this.root === 'curupdate') {
        // 最近更新
        bCheck = checkedArr.length === this.recent.length
      } else {
        bCheck = checkedArr.length === this.tableCount
      }
      this.$set(this.batch, 'allChecked', bCheck)
      this.batch.checkedCount = checkedArr.length
    },
    checkImg(value) {
      if (checkform(value, 'Img')) {
        return false
      } else {
        return true
      }
    },
    refreshRightFun(val) {
      if (val) {
        this.sortTableObj.sortTodo = false
        bus.$emit('kmDetailClearSort')
      }
      let to = this.$route
      this.input2 = ''
      this.isSearch = false
      this.showItem = true
      this.ifEdit = false
      this.ifContent = false
      this.ifAdd = false
      this.ok = true
      // 搜索后单击标题显示详情，右侧刷新时赋值false
      this.isSearchDetail = false
      if (to.path.split('/')[4] === 'curupdate') {
        this.root = 'curupdate'
        let catapath1 = '/index/km/' + this.$route.fullPath.split('/')[3] + '/curupdate'
        this.cataPath = [catapath1, '', '', '', '']
        this.newCatalogue = ['', '', '', '', '']
        this.cataLength = 1
        this.recentList(this.recentSearchType)
      } else {
        this.newCatalogue = [this.$t('km.viewCategory'), '', '', '', '']
        this.cataLength = 1
        this.root = ''
        // ‘init'跳到第一页，否则刷新当页
        if (val && val.type === 'init') {
          this.tablePage = 1
        }
        to.params.kmId && this.queryItemList()
        to.params.kmId && this.changeCatalogue()
      }
    },
    closeBigImage() {
      this.bigImage.bigImageShow = false
      this.bigImage.url = ''
    },
    // 查看大图片
    showBigImage(_data) {
      let data = _data.url
      // 获取所有包含imgA的图片
      let _array = this.$el.querySelectorAll('.km-file .imgA')
      commitImgType2(data, _array)
    },
    sorTableFun(data) {
      let direction = data.order === 'ascending' ? '1' : data.order === 'descending' ? '-1' : ''
      let sortType = data.prop
      if (sortType === 'date') {
        sortType = 'lastTime'
      } else if (sortType === 'clickrate') {
        sortType = 'hits'
      }
      this.sortTableObj.sortTodo = true
      this.sortTableObj.sortType = sortType
      this.sortTableObj.sortDirection = direction
      this.refreshRightFun()
    },
    superAClickFun(e) {
      e.preventDefault()
      this.$nextTick(() => {
        if (e.target.nodeName.toLowerCase() === 'a') {
          let dom = e.target
          let domUrl = dom.getAttribute('href')
          try {
            window.open(domUrl, '_blank')
          } catch (e) {
            this.$message.error(this.$t('webchat.urlError'))
          }
        }
      })
    },
    // 修改当前位置
    changeCatalogue(flag, id) {
      let catalogTree = this.$store.state.km.catalogTree || []
      let _id = this.$route.params.kmId
      if (flag === 'search') {
        _id = id
      }
      if (_id === '0') {
        //            this.catalogue = ' '
        let catapath1 = '/index/km/' + this.$route.fullPath.split('/')[3] + '/all'
        this.cataPath = [catapath1, '', '', '', '']
        this.newCatalogue = [this.$t('km.viewCategory'), '', '', '', '']
        this.cataLength = 1
        return
      }
      for (let i = 0; i < catalogTree.length; i++) {
        let catalog = catalogTree[i]
        if (catalog._id === _id) {
          let catapath1 = '/index/km/' + this.$route.fullPath.split('/')[3] + '/all'
          let catapath2 = '/index/km/' + this.$route.fullPath.split('/')[3] + '/' + catalog._id
          this.cataPath = [catapath1, catapath2, '', '', '']
          this.newCatalogue = [this.$t('km.viewCategory'), catalog.name, '', '', '']
          this.cataLength = 2
          //              this.catalogue = ' ' + catalog.name
          break
        } else {
          let childs1 = catalog.childs
          for (let i = 0; i < childs1.length; i++) {
            let child1 = childs1[i]
            if (child1._id === _id) {
              let catapath1 = '/index/km/' + this.$route.fullPath.split('/')[3] + '/all'
              let catapath2 = '/index/km/' + this.$route.fullPath.split('/')[3] + '/' + catalog._id
              let catapath3 = '/index/km/' + this.$route.fullPath.split('/')[3] + '/' + child1._id
              this.cataPath = [catapath1, catapath2, catapath3, '', '']
              this.newCatalogue = [this.$t('km.viewCategory'), catalog.name, child1.name, '', '']
              this.cataLength = 3
              //                  this.catalogue = ' ' + catalog.name + ' > ' + child1.name
              break
            } else {
              let childs2 = child1.childs
              for (let i = 0; i < childs2.length; i++) {
                let child2 = childs2[i]
                if (child2._id === _id) {
                  let catapath1 = '/index/km/' + this.$route.fullPath.split('/')[3] + '/all'
                  let catapath2 = '/index/km/' + this.$route.fullPath.split('/')[3] + '/' + catalog._id
                  let catapath3 = '/index/km/' + this.$route.fullPath.split('/')[3] + '/' + child1._id
                  let catapath4 = '/index/km/' + this.$route.fullPath.split('/')[3] + '/' + child2._id
                  this.cataPath = [catapath1, catapath2, catapath3, catapath4, '']
                  this.newCatalogue = [this.$t('km.viewCategory'), catalog.name, child1.name, child2.name, '']
                  this.cataLength = 4
                  //                      this.catalogue = ' ' + catalog.name + ' > ' + child1.name + ' > ' + child2.name
                  break
                }
              }
            }
          }
        }
      }
    },
    replaceKeyWord(html, keyWord) {
      if (keyWord) {
        if (checkform(keyWord, 'hasChinese')) {
          // 关键字没有中文不标红
          return html
        }
        let reg = new RegExp(keyWord, 'g')
        return html.replace(reg, '<strong style="color:red; cursor: pointer">' + keyWord + '</strong>')
      }
      return html
    },
    queryItemList() {
      if (this.tablePage < 1 || this.tablePage === '' || this.tablePage == null) {
        this.tablePage = 1
      }
      let kmId = 'all'
      if (this.$route.params.kmId !== 'curupdate') {
        kmId = this.$route.params.kmId
      }
      let data = {
        cid: kmId,
        kmType: this.KmType,
        page: this.tablePage
      }
      this.$emit('addData', data)
      let obj = {}
      if (this.sortTableObj.sortTodo && this.sortTableObj.sortDirection) {
        data.sortType = this.sortTableObj.sortType
        data.sortDirection = parseInt(this.sortTableObj.sortDirection)
      }
      this.loading = true
      return this.$store
        .dispatch('queryItemList', data)
        .then(() => {
          let itemList = this.$store.state.km.itemList
          let totalPage = Math.ceil(itemList.count / 10)
          totalPage = totalPage || 1
          let recentList = itemList.list
          let arr = []
          for (let i = 0; i < recentList.length; i++) {
            obj = {
              title: recentList[i].title,
              name: this.getDisplayName(recentList[i].updateUser || recentList[i].publisher),
              date: recentList[i].lastTime,
              createTime: recentList[i].createTime,
              clickrate: recentList[i].hits,
              _id: recentList[i]._id,
              cid: recentList[i].cid,
              kmType: recentList[i].kmType,
              placeTop: recentList[i].placeTop,
              tagList: recentList[i].tagList,
              status: recentList[i].status,
              validityPeriodType: recentList[i].validityPeriodType,
              validityPeriod: recentList[i].validityPeriod
            }
            arr.push(obj)
          }
          this.tableData = arr
          this.tableCount = itemList.count
          this.tableTotalPage = totalPage
          this.loading = false
        })
        .catch(() => {
          this.loading = false
        })
    },
    getDisplayName(id) {
      let agent = this.$agentsMap() || {}
      return agent[id] ? agent[id].displayName : ''
    },
    editText(item) {
      item.kmType = this.KmType
      this.$refs.searchEditModules.fetchData(item._id)
      this.isSearch = true
      this.searchEdit = true
      this.searchList = false
      this.searchItemShow = false
      this.searchBack = true
      this.showItem = false
      this.$nextTick(() => {
        this.$el.getElementsByClassName('searchResultBox')[0].scrollTop = 0
      })
    },
    delText(item) {
      this.$confirm(this.$t('public.confirmDel'), this.$t('public.operate'), {
        confirmButtonText: this.$t('public.confirm'),
        cancelButtonText: this.$t('public.cancel'),
        cancelButtonClass: 'primary_btn',
        confirmButtonClass: 'primary_btn',
        type: 'warning'
      })
        .then(() => {
          let data = {
            _id: item._id,
            kmType: this.KmType
          }
          this.$store.dispatch('delItem', data).then(() => {
            this.handleIconClick()
          })
          this.$message({
            type: 'success',
            message: this.$t('km.deleteSucc')
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: this.$t('km.cannelDel')
          })
        })
    },
    currentChange(currentPage) {
      this.tablePage = currentPage || 1
      this.queryItemList()
    },
    dicPageChange(currentPage) {
      this.page = currentPage
      this.search(currentPage)
    },
    pages(pages) {
      this.tablePage = pages.page
      this.tableTotalPage = pages.totalPage
      this.tableCount = pages.count
    },
    onSubmit() {
      console.log('submit!')
    },
    search(page) {
      if (page == null) {
        page = this.page
      }
      let data = {
        key: this.input2,
        page: page,
        kmType: this.KmType
      }
      let cid = this.$route.path.split('/')[4]
      if (cid && cid !== 'curupdate' && cid !== 'all') {
        data.cids = this.searchCids(cid)
        this.showCatalogue(cid)
      } else {
        this.showCatalogue(0)
      }
      this.$store.dispatch('queryKmDic', data).then(() => {
        let list = this.$store.state.km.kmDic.list
        this.count = this.$store.state.km.kmDic.count
        this.totalPage = Math.ceil(this.count / 10)
        this.totalPage = this.totalPage || 1
        this.list = deepClone(list)
        for (let k = 0; k < this.list.length; k++) {
          let catalogTree = this.$store.state.km.catalogTree
          let _id = this.list[k].cid
          this.list[k].title = filterXSS(this.list[k].title)
          this.list[k].content = filterXSS(this.list[k].content || '', true)
          for (var i = 0; i < catalogTree.length; i++) {
            let catalog = catalogTree[i]
            if (catalog._id === _id) {
              this.list[k].catalog = this.$t('km.mulu') + catalog.name
              break
            } else {
              let childs1 = catalog.childs
              for (var j = 0; j < childs1.length; j++) {
                let child1 = childs1[j]
                if (child1._id === _id) {
                  this.list[k].catalog = this.$t('km.mulu') + catalog.name + ' > ' + child1.name
                  break
                } else {
                  let childs2 = child1.childs
                  for (var m = 0; m < childs2.length; m++) {
                    let child2 = childs2[m]
                    if (child2._id === _id) {
                      this.list[k].catalog =
                        this.$t('km.mulu') + catalog.name + ' > ' + child1.name + ' > ' + child2.name
                      break
                    } else {
                      //                        this.list[k].catalog = this.$t('km.mulu1')
                    }
                  }
                }
              }
            }
          }
        }
        this.$nextTick(() => {
          this.$el.getElementsByClassName('searchResultBox')[0].scrollTop = 0
        })
      })
    },
    plus() {
      this.ok = false
      this.ifAdd = true
      this.ifEdit = false
      this.ifContent = false
    },
    addContent() {
      this.ifAdd = false
      this.ok = true
      this.ifEdit = false
      this.ifContent = false
      this.root = ''
      this.$route.params.kmId && this.queryItemList()
    },
    addData(addData) {
      this.addId = addData
    },
    cancel() {
      this.ifAdd = false
      this.ok = true
      this.ifEdit = false
      this.ifContent = false
    },
    editBtnContent(row) {
      for (let i = 0; i < this.newCatalogue.length; i++) {
        if (this.newCatalogue[i] === '') {
          this.cataPath[i] = '1'
          this.newCatalogue[i] = row.title + this.$t('public.edit')
          this.cataLength = i + 1
          break
        }
      }
      this.ifEdit = true
      this.ok = false
      this.ifAdd = false
      this.ifContent = false
      this.editdata = row
      this.$refs.editModules.fetchData(row._id)
    },
    editBtnContent1(row) {
      if (row.catalog) {
        this.showCatalogue(row.cid)
        this.cataLength = this.cataLength + 1
        this.cataPath[this.cataLength - 1] = '1'
        this.newCatalogue[this.cataLength - 1] = row.title + this.$t('public.edit')
      }
      this.ifEdit = true
      this.ok = false
      this.ifAdd = false
      this.ifContent = false
      this.editdata = row
      this.$refs.editModules.fetchData(row._id)
    },
    editContent(editdata) {
      this.ifEdit = false
      this.ifAdd = false
      this.ok = true
      this.ifContent = false
      this.queryItemList()
      if (this.isSearch === true) {
        this.handleIconClick(true)
      } else {
        this.$store.commit('km/REFRESH_RIGHT', { type: 'cache' })
      }
    },
    showContent(row) {
      this.ifEdit = false
      this.ifAdd = false
      this.ok = false
      this.title = filterXSS(row.title)
      let data = {
        _id: row._id,
        kmType: row.kmType,
        flag: 'view'
      }
      let ItemEditdata = {}
      this.$store.dispatch('showItemEdit', data).then(() => {
        ItemEditdata = this.$store.state.km.ItemEditdata
        this.ifContent = true
        // xss处理
        this.ItemContent = filterXSS(ItemEditdata.row.content, true)
        this.attached = ItemEditdata.row.attachs
        this.tagList = ItemEditdata.row.tagList
        if (this.$route.path.split('/')[4] === 'curupdate') {
          this.showCatalogue(ItemEditdata.row.catalog._id)
        }
        // 显示table具体内容上的 导航
        for (let i = 0; i < this.newCatalogue.length; i++) {
          if (this.newCatalogue[i] === '') {
            this.cataPath[i] = '1'
            this.newCatalogue[i] = ItemEditdata.row.title
            this.cataLength = i + 1
            break
          }
        }
      })
    },
    showSearchContent(row) {
      let data = {
        _id: row._id,
        kmType: this.KmType,
        flag: 'view'
      }
      let ItemEditdata = {}
      this.$store.dispatch('showItemEdit', data).then(() => {
        ItemEditdata = this.$store.state.km.ItemEditdata
        this.ifContent = true
        if (row.catalog) {
          this.showCatalogue(row.cid)
          this.cataLength = this.cataLength + 1
          this.cataPath[this.cataLength - 1] = '1'
          this.newCatalogue[this.cataLength - 1] = row.titleText
        }
        this.tagList = ItemEditdata.row.tagList
        this.title = ItemEditdata.row.title
        // xss处理
        this.ItemContent = filterXSS(ItemEditdata.row.content, true)
        this.attached = ItemEditdata.row.attachs
        console.log(this.attached)
        this.ifEdit = false
        this.ifAdd = false
        this.ok = false
        this.isSearchDetail = true
        this.isSearch = true
        this.searchEdit = false
        this.searchList = false
        this.searchItemShow = true
        this.searchBack = true
        this.showItem = false
        this.$nextTick(() => {
          this.$el.getElementsByClassName('searchResultBox')[0].scrollTop = 0
        })
      })

      this.changeCatalogue('search', row._id)
    },
    back() {
      this.ifEdit = false
      this.ifAdd = false
      this.ok = true
      this.ifContent = false
      this.$store.commit('km/REFRESH_RIGHT', { type: 'cache' })
      if (this.isSearchDetail) {
        this.showItem = false
        this.isSearch = false
        this.isSearchDetail = false
      }
    },
    // 置顶    ============
    handlePlaceTop(row, flag) {
      let data = {
        _id: row._id,
        kmType: row.kmType,
        placeTop: flag
      }
      console.log(data)
      this.$store.dispatch('kmPlaceTop', data).then(() => {
        this.queryItemList()
      })
    },
    searchCids(cid) {
      let tree = this.$store.state.km.catalogTree
      let currentTree = {}
      function currentModel(cid, data) {
        for (let i = 0; i < data.length; i++) {
          let item = data[i]
          if (cid === item._id) {
            currentTree = item
            break
          } else {
            currentModel(cid, item.childs)
          }
        }
      }
      currentModel(cid, tree)
      let arr = [cid]
      function findcids(currentTree) {
        let childs = currentTree.childs || []
        for (let i = 0; i < childs.length; i++) {
          let item = childs[i]
          arr.push(item._id)
          findcids(item)
        }
      }
      findcids(currentTree)
      return arr
    },
    searchBackFun() {
      this.handleIconClick(true)
    },
    handleIconClick(flag) {
      if (typeof flag === 'boolean') {
        this.tablePage = 1
        this.isSearch = true
        this.searchList = true
        this.searchEdit = false
        this.searchItemShow = false
        this.searchBack = false
        this.showItem = false
        if (this.input2) {
          this.search()
        }
      } else if (this.input2) {
        // 搜索时table页数初始化
        this.tablePage = 1
        this.isSearch = true
        this.searchList = true
        this.searchEdit = false
        this.searchItemShow = false
        this.searchBack = false
        this.showItem = false
        this.page = 1
        this.search()
        // 搜索时清空批量操作
        this.checkNone()
      }
      this.$nextTick(() => {
        this.$el.getElementsByClassName('searchResultBox')[0].scrollTop = 0
      })
    },
    recentList(timeType = 'day') {
      this.loading = true
      let data = {
        kmType: this.KmType,
        timeType
      }
      if (timeType !== this.recentSearchType) {
        this.sortTableObj.sortTodo = false
        bus.$emit('kmDetailClearSort')
      } else {
        if (this.sortTableObj.sortTodo && this.sortTableObj.sortDirection) {
          data.sortType = this.sortTableObj.sortType
          data.sortDirection = parseInt(this.sortTableObj.sortDirection)
        }
      }
      this.$store.dispatch('queryRecentList', data).then(() => {
        this.loading = false
        this.recentSearchType = timeType
      })
    },
    showCatalogue(_id) {
      let catalogTree = this.$store.state.km.catalogTree
      if (_id === 0) {
        this.newCatalogue = [this.$t('km.viewCategory'), '', '', '', '']
        return
      }
      for (let i = 0; i < catalogTree.length; i++) {
        let catalog = catalogTree[i]
        if (catalog._id === _id) {
          let catapath1 = '/index/km/' + this.$route.fullPath.split('/')[3] + '/all'
          let catapath2 = '/index/km/' + this.$route.fullPath.split('/')[3] + '/' + catalog._id
          this.cataPath = [catapath1, catapath2, '', '', '']
          this.newCatalogue = [this.$t('km.viewCategory'), catalog.name, '', '', '']
          this.cataLength = 2
          //            this.catalogue = catalog.name + ' > '
          break
        } else {
          let childs1 = catalog.childs
          for (let i = 0; i < childs1.length; i++) {
            let child1 = childs1[i]
            if (child1._id === _id) {
              let catapath1 = '/index/km/' + this.$route.fullPath.split('/')[3] + '/all'
              let catapath2 = '/index/km/' + this.$route.fullPath.split('/')[3] + '/' + catalog._id
              let catapath3 = '/index/km/' + this.$route.fullPath.split('/')[3] + '/' + child1._id
              this.cataPath = [catapath1, catapath2, catapath3, '', '']
              this.newCatalogue = [this.$t('km.viewCategory'), catalog.name, child1.name, '', '']
              this.cataLength = 3
              //                this.catalogue = catalog.name + ' > ' + child1.name + ' > '
              break
            } else {
              let childs2 = child1.childs
              for (let i = 0; i < childs2.length; i++) {
                let child2 = childs2[i]
                if (child2._id === _id) {
                  let catapath1 = '/index/km/' + this.$route.fullPath.split('/')[3] + '/all'
                  let catapath2 = '/index/km/' + this.$route.fullPath.split('/')[3] + '/' + catalog._id
                  let catapath3 = '/index/km/' + this.$route.fullPath.split('/')[3] + '/' + child1._id
                  let catapath4 = '/index/km/' + this.$route.fullPath.split('/')[3] + '/' + child2._id
                  this.cataPath = [catapath1, catapath2, catapath3, catapath4, '']
                  this.newCatalogue = [this.$t('km.viewCategory'), catalog.name, child1.name, child2.name, '']
                  this.cataLength = 4
                  //                    this.catalogue = catalog.name + ' > ' + child1.name + ' > ' + child2.name + ' > '
                  break
                }
              }
            }
          }
        }
      }
    },
    // dialog打开
      open (type) {
        this.dialogVisible = true
        this.importShow = false
        this.dialogType = type
        this.importErrRows = []
        if (type === 'export') {
          this.treeData[0].childs = this.treeChilds
          this.$nextTick(() => {
            this.$refs.export.reset()
          })
        }
      },
      // 导入请求
      importExcel () {
        this.$store.dispatch('importKmItem', this.importObj).then((resp) => {
          if (resp.success) {
            this.$message.success(this.$t('km.importTask'))
            this.importShow = false
            this.importObj.titleRepeat = 'cover'
            this.dialogVisible = false
          }
        })
      },
      // 导出
      exportExcel () {
          if (this.delTags) {
            this.exportExcelDelTags()
          } else {
            this.exportExcelNoDelTags()
          }
      },
      exportExcelDelTags () {
        let categories = this.$refs.export.checkedArr.filter(item => item !== '0')
        if (!categories.length) {
          this.$message.error(this.$t('km.pleaseChoice'))
          return
        }
        let data = {
          kmType: this.KmType,
          delTags: this.delTags,
          batchNo: getDateNo(),
          categories
        }
        this.$store.dispatch('addKmExportTask', data).then((resp) => {
          if (resp.success) {
            if(resp.message === 'no permission'){
              this.$message.error(this.$t('webchat.exportError2'))
              this.dialogVisible = false
              return
            }
            this.$message.success(this.$t('webchat.exportSuccess'))
            this.dialogVisible = false
          } else {
            this.$message.error(this.$t('message.'+ resp.message))

          }
        })
      },
      exportExcelNoDelTags () {
        let categories = this.$refs.export.checkedArr.filter(item => item !== '0')
        if (!categories.length) {
          this.$message.error(this.$t('km.pleaseChoice'))
          return
        }
        let data = {
          Method: 'exportKm',
          Query: {
            kmType: this.KmType,
            categories
          }
        }
        this.$store.dispatch('exportXls', data).then((res) => {
          if (res.success) {
            this.$message.success(this.$t('webchat.exportSuccess'))
            this.dialogVisible = false
          }
        })
      },
      // 上传前 配置上传参数
      beforeUpload (file) {
        this.uploadHeaders.key = 'file'
        this.uploadHeaders.name = file.name
        let arr = file.name.split('.')
        let arrType = ['xls', 'xlsx']
        if (arrType.indexOf(arr[arr.length - 1]) !== -1) {
          return true
        } else {
          this.$message.error(this.$t('km.fileTypeError'))
          return false
        }
      },
      // 上传成功
      handleSuccess (response, file, fileList) {
        if (response.success) {
          this.dialogLoading = true
          let fileName = response.filePath.substring(response.filePath.lastIndexOf('/') + 1)
          let trueName = response.fileName
          this.getXlsHeads(trueName, fileName)
        } else {
          this.$message.error(this.$t('message.default_tips'))
        }
      },
      // 失败
      handleError () {
        this.$message.error(this.$t('message.default_tips'))
      },
      // 校验格式是否正确
      getXlsHeads (trueName, fileName) {
        this.$store.dispatch('getXlsHeadsKm', {trueName, fileName, kmType: this.KmType}).then((resp) => {
          this.dialogLoading = false
          if (resp.success) {
            this.importShow = true
            this.importObj.batchNo = getDateNo()
            this.importObj.batchRemark = ''
            this.importObj.trueName = trueName
            this.importObj.fileName = fileName
            this.importObj.kmType = this.KmType
            if (this.KmType === 'inner') {
              this.importObj.heads = ['firstLevelDirectory', 'secondLevelDirectory', 'thirdLevelDirectory', 'title', 'content', 'validityPeriodType', 'tagList']
            } else {
              this.importObj.heads = ['firstLevelDirectory', 'title', 'content', 'validityPeriodType', 'tagList']
            }
            this.importObj.xlsHeads = JSON.stringify(resp.heads)
            this.importErrRows = []
          } else {
            this.importShow = false
            this.importErrRows = resp.importErrRows || []
          }
        })
      },
      fetchTreeData (flag) {
        // 从路由获取kmType，解决tab切换，从props中获取kmType不准问题
        let kmType = this.$route.path.split('/')[3] === 'inner' ? 'inner' : 'outer'
        let data = {
          kmType: flag || kmType,
          type: this.type
        }
        this.$store.dispatch('queryCatalogList', data).then((res) => {
          // this.treeData.childs = res
        })
      }
    },
    beforeMount() {
      console.log(this.treeChilds, 22222)
    this.isSearch = false
    this.searchEdit = false
    this.searchList = false
    this.searchItemShow = false
    this.searchBack = false
    this.showItem = true
    if (this.$route.path.split('/')[4] === 'curupdate') {
      this.root = 'curupdate'
      this.recentList()
      //        this.queryItemList()
    } else {
      this.root = ''
      this.$route.params.kmId && this.changeCatalogue()
    }
    if (isHasFunc('func_not_remove_km_content', this.$store.state.session.user)) { // 禁止删除知识库内容-func_not_remove_km_content
      this.forbiddenDelete = true
    } else if (isHasFunc('func_km_config', this.$store.state.session.user) && this.deptPower) {
      this.batch.operator.push({
        name: 'public.delete',
        class: 'iconfont icon-shanchu',
        action: 'onDelete'
      })
    }
    if (isHasFunc('func_km_config', this.$store.state.session.user)) {
      this.hasManage = true
      this.batch.operator.push(
        {
          name: 'km.modifyDirectory',
          class: 'iconfont icon-biaodan',
          action: 'onModifyCid'
        },
        {
          name: 'km.modifyValidity',
          class: 'iconfont icon-yanshi',
          action: 'onModifyDate'
        })
    }
    if (isHasFunc('func_km_placeTop', this.$store.state.session.user)) {
      this.forbiddenPlaceTop = true
    }
    if (isHasFunc('func_km_import', this.$store.state.session.user)) {
        this.showImport = true
    }
    if (isHasFunc('func_km_export', this.$store.state.session.user)) {
      this.showExport = true
    }
  },
  components: {
    KmTable,
    KmNewAdd,
    KmModify,
    KmComment,
    BreadCrumb,
    globalPopup,
    knowledgeLabel,
    cardBatch,
    kmTree,
    exportCatalogue
  }
}
</script>
<style lang="stylus" rel="stylesheet/stylus" scoped>
@import "../../../../assets/common.styl"
.instructions
  clear both
  font-size 12px
  line-height 22px
  color $c-prompt
.btn-wrap
  padding-bottom 10px
  overflow hidden
  .temp-download
    float left
    a
      color #fff
  .temp-upload
    float left
    display inline-block
    margin-left 20px
    .temp-upload-btn
      font-size 12px
      padding 8px 15px
.custom_time
  &.el-date-editor
    width 400px
    margin 10px 0 0 86px
    /deep/.el-input__icon, /deep/.el-range-separator
      line-height 22px
.batch
  width calc(100vw - 57px - 10px - 439px)
.navMenuState
  width calc(100vw - 57px - 10px - 503px)
.km-detail
  margin-left 428px
  width calc(100vw - 485px)
  .icon-yulan
    color $c-main
    cursor pointer
  .file
    padding-top 5px
  .result
    .head
      margin 24px 0 8px 0
      height 20px
      h3
        font-size 14px
        cursor pointer
        color $cf-gray2
        font-weight 700
      .iconfont
        cursor pointer
        font-size 12px
      .icon-guanbi
        color $c-pink
      .icon-beizhu
        color $c-main
        margin-right 16px
    p
      font-size 12px
      color $cf-gray3
      line-height 22px
      margin-top 10px
    .detai
      color $cf-gray4
  .find
    height 40px
    border none
    padding 0
    .high
      color $c-prompt
  .searc
    height 50px
    line-height 50px
    border-bottom 1px solid $cf-level5
    padding-right 20px
  .public
    padding-bottom 20px
    height calc(100vh - 146px)
    overflow-y auto
  .searchResult
    padding 16px 26px 0 36px
    height calc(100vh - 180px)
  .searchResultBox
    height calc(100vh - 202px)
    overflow-y auto
.catalogue-list
  color $cf-gray4
  font-size 14px
  font-weight 500
  margin-bottom 22px
.km-keyword-search-form
  height 36px
  line-height 36px
  padding 9px 14px
  color $cf-gray1
  border 1px solid #dddddd
  border-bottom none
  .keywrod-wrap
    float left
    line-height 40px
    .search-bread
      display inline-block
      padding-right 5px
    .search-hight
      border-left 1px solid $cf-level2
  .search
    float left
    .pd
      display inline-block
      float left
      line-height 36px
      color $c-main
      span
        margin-right 20px
        cursor pointer
      .delete
        color $c-pink
  .page
    float right
    height 36px
    line-height 36px
    .all
      margin 0px 6px 0 0
    .currentpage
      float left
    .el-pagination
      float left
      padding 7px 5px
      color $cf-gray5
.open
  display none
.close
  display block
.contentDetails
  color $cf-gray3
  .content-title
    color $cf-gray1
    font-size 18px
    text-align center
    margin-bottom 32px
  .content
    font-size 12px
    line-height 28px
    overflow auto
    max-height calc(100vh - 278px)
  .back
    margin-top 28px
    margin-bottom 50px
  .comment
    margin-top 50px
.km-detail.navMenu
  width calc(100vw - 558px)
.el-icon-arrow-left
  color $c-main
  display inline-block
  width 18px
  height 18px
  line-height 18px
  border 1px solid $c-main
  border-radius 50%
  text-align center
  font-size 12px
  cursor pointer
.searchResult
  .modification
    overflow hidden
    padding-right 16px
  .contentDetails
    padding-right 16px
</style>
